﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace LNUGame.Model
{
    /// <summary>
    /// Represents a collisionhandler between two circles
    /// </summary>
    class Collider
    {
        Vector2 m_position = new Vector2();
        float m_radius = 1;

        /// <summary>
        /// Creates a new collider to be used
        /// </summary>
        /// <param name="a_pos"></param>
        /// <param name="a_radius"></param>
        public Collider(Vector2 a_pos, float a_radius)
        {
            m_position = a_pos;
            m_radius = a_radius;
        }

        /// <summary>
        /// Simple circle-circle collision.
        /// Checks if the radii between two sprites is bigger than 
        /// </summary>
        /// <param name="a_other"></param>
        /// <returns></returns>
        internal bool DoCollide(Collider a_other)
        {
            Vector2 line = m_position - a_other.m_position;
            float distance = line.Length();

            if (distance < m_radius + a_other.m_radius)
            {
                return true;
            }

            return false;
        }
    }
}
